﻿namespace HySoft.Cash.Structure
{
    using System;
    using System.Data;
    using HiLand.Utility.DataBase;

    public class TemppaymentDT
    {
        public static TemppaymentDT ConvertFrom(DataRow row)
        {
            TemppaymentDT entity = new TemppaymentDT();
            if (row != null)
            {
                entity.Sid = Convert.ToInt32(row["Sid"]);
                entity.EmpSid = Convert.ToInt32(row["EmpSid"]);
                entity.BankSid = Convert.ToInt32(row["BankSid"]);
                entity.PaymentDate = Convert.ToDateTime(row["PaymentDate"]);
                entity.PaymentAmount = Convert.ToDecimal(row["PaymentAmount"]);
                entity.PaymentDD = Convert.ToString(row["PaymentDD"]);
                entity.PaymentMM = Convert.ToString(row["PaymentMM"]);
                entity.PaymentYY = Convert.ToString(row["PaymentYY"]);
                entity.OrgSid = Convert.ToInt32(row["OrgSid"]);
                entity.InvoiceID = new Guid(Convert.ToString(row["InvoiceID"]));
                try
                {
                    entity.InvoiceDate = Convert.ToDateTime(row["InvoiceDate"]);
                }
                catch { }

                entity.InvoiceStatus = (PaymentStatuses)Convert.ToInt32(row["InvoiceStatus"]);
                entity.other1 = (PayManualStatuses)Convert.ToInt32(row["other1"]);
                entity.other2 = Convert.ToInt32(row["other2"]);
                if (DataRowHelper.IsExistField(row, "ReferenceInfo"))
                {
                    entity.ReferenceInfo = Convert.ToString(row["ReferenceInfo"]);
                }
                else
                {
                    entity.ReferenceInfo = Convert.ToString(row["other3"]);
                }

                entity.other4 = Convert.ToString(row["other4"]);
            }

            return entity;
        }


        public static string AllFields = "Sid,EmpSid,BankSid,PaymentDate,PaymentAmount,PaymentDD,PaymentMM,PaymentYY,OrgSid,InvoiceID,InvoiceDate,InvoiceStatus,other1,other2,other3 as ReferenceInfo,other4";
        public int BankSid;
        public int EmpSid;
        public int OrgSid;
        public decimal PaymentAmount;
        public DateTime PaymentDate;
        public string PaymentDD;
        public string PaymentMM;
        public string PaymentYY;
        public int Sid;
        public Guid InvoiceID;
        public DateTime InvoiceDate = new DateTime(1900,1,1);
        public PaymentStatuses InvoiceStatus;
        
        /// <summary>
        /// 表示本payment是否已付（0表示未付，1表示已付）
        /// </summary>
        public PayManualStatuses other1;
        public int other2;

        /// <summary>
        /// 表示本付款的目的（养老金还是退休金等）
        /// </summary>
        public string ReferenceInfo;

        public string other4;
    }

    public enum PaymentStatuses
    { 
        NeedDeal=0,
        DealDone=1,
    }

    /// <summary>
    /// 管理员付款状态
    /// </summary>
    public enum PayManualStatuses
    { 
        NeedPay=0,
        Paid= 1,
    }
}

